# Maintainer: Andrew Sun <adsun701@gmail.com>

_realname=tox
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=4.3.5
pkgrel=1
pkgdesc="Python virtualenv management and testing tool (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://tox.readthedocs.io"
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-hatchling"
             "${MINGW_PACKAGE_PREFIX}-python-hatch-vcs")
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-cachetools"
         "${MINGW_PACKAGE_PREFIX}-python-chardet"
         "${MINGW_PACKAGE_PREFIX}-python-colorama"
         "${MINGW_PACKAGE_PREFIX}-python-packaging"
         "${MINGW_PACKAGE_PREFIX}-python-platformdirs"
         "${MINGW_PACKAGE_PREFIX}-python-pluggy"
         "${MINGW_PACKAGE_PREFIX}-python-pyproject-api"
         "${MINGW_PACKAGE_PREFIX}-python-tomli"
         "${MINGW_PACKAGE_PREFIX}-python-virtualenv"
         "${MINGW_PACKAGE_PREFIX}-python-filelock"
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('307993257d792a12a63ff86a0b67a71a5ab2d4a2cc12bbae947115224d4ac3fb')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

#This hangs when I try this.
#check() {
#  cd "${srcdir}/python-build-${MSYSTEM}"
#  msg "Python build for ${MSYSTEM}"
#  ${MINGW_PREFIX}/bin/virtualenv "$srcdir/pyvenv" --system-site-packages
#  . "$srcdir/pyvenv/bin/activate"
#  ${MINGW_PREFIX}/bin/python setup.py install
#  ${MINGW_PREFIX}/bin/python setup.py pytest
#
#}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
